# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>
# stolen from Archlinux
_realname=docbook-sgml
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.5
pkgrel=2
pkgdesc='Document type definitions for verification of SGML data files against the DocBook rule set. (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://www.docbook.org/sgml/'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-sgml-common")
install="docbook-sgml-${MSYSTEM}.install"
source=("https://www.docbook.org/sgml/${pkgver}/docbook-${pkgver}.zip")
sha256sums=('8043e514e80c6c19cb146b5d37937d1305bf3abf9b0097c36df7f70f611cdf43')

build() {
  cd "$srcdir"

  local DTDDIR="${MINGW_PREFIX}/share/sgml/docbook-sgml-$pkgver"

  sed -i \
      -e '/ISO 8879/d' \
      -e '/gml/d' \
      docbook.cat

  # Add support for previous versions.
  cat >> docbook.cat << "EOF"

  -- Begin Single Major Version catalog changes --

PUBLIC "-//OASIS//DTD DocBook V4.4//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.3//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.1//EN" "docbook.dtd"
PUBLIC "-//OASIS//DTD DocBook V4.0//EN" "docbook.dtd"

  -- End Single Major Version catalog changes --

EOF
}

package() {
  cd "$srcdir"

  local DTDDIR="${MINGW_PREFIX}/share/sgml/docbook-sgml-$pkgver"

  install -dm755 "$pkgdir/$DTDDIR"
  install -m644 docbook.cat "$pkgdir/$DTDDIR/catalog"
  install -m644 *.dtd *.mod *.dcl "$pkgdir/$DTDDIR"
}
